#include <stdio.h>
#include <algorithm>

typedef long long int ll;

int n, m, res = 999;
ll a[10003] = {0};
ll S[10003] = {0};

ll test(int pos)
{
	ll p = (a[pos] > a[0]) ? (a[pos] - a[0]) : (a[0] - a[pos]);
	ll q = (a[n] > a[pos]) ? (a[n] - a[pos]) : (a[pos] - a[n]);
	ll r = p - q;
}

void doit(int begin, int end, int cnt)
{
	int last = test(1);
	int now;
	int pos;
	for (pos = begin; pos <= end; ++pos)
	{
		now = test(pos);
		if (last * now < 0)
			break;
	}
	res = (last > now) ? now : last;
	doit(begin, pos - 1, cnt + 1);
	doit(pos, end, cnt + 2);
}

int main()
{
	scanf ("%d%d", &n, &m);
	for (int i = 1; i < n; ++i)
	{
		scanf("%d", a + i);
		S[i] = S[i - 1] + a[i];
	}
	doit(1, n, 2);
	return 0;
}